<template>
<section>
    <section class="mk-add-pop">
        <el-form ref="formAdd" :model="form" :rules="rules" label-width="100px">
            <mk-get-row>
                <el-form-item label="项目名称" prop="name">
                    <el-input v-model="form.name" size="mini" class="input-one" clearable placeholder="请输入项目名称"></el-input>
                </el-form-item>
            </mk-get-row>

            <mk-get-row>
                <el-form-item label="开始时间" prop="startTime">
                    <el-date-picker v-model="form.startTime" type="month" placeholder="选择开始时间">
                    </el-date-picker>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="结束时间" prop="endTime">
                    <el-date-picker v-model="form.endTime" type="month" placeholder="选择结束时间">
                    </el-date-picker>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="项目周期">
                    <el-input v-model="form.cycle" size="mini" class="input-one" clearable placeholder="请输入项目周期"></el-input>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="项目描述" prop="description">
                    <el-input v-model="form.description" size="mini" type="textarea" :rows="3" style="width: 450px" clearable placeholder="请输入项目描述"></el-input>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="项目职责" prop="duty">
                    <el-input v-model="form.duty" size="mini" type="textarea" :rows="3" style="width: 450px" clearable placeholder="请输入项目职责"></el-input>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="是否有效" prop="type">

                    <el-radio-group v-model="form.show" size="mini">
                        <el-radio :label="1" border>是</el-radio>
                        <el-radio :label="0" border>否</el-radio>
                    </el-radio-group>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="链接">
                    <el-input v-model="form.link" size="mini" class="input-one" clearable placeholder="请输入链接"></el-input>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="业绩">
                    <el-input v-model="form.achieve" size="mini" class="input-one" clearable placeholder="请输入业绩"></el-input>
                </el-form-item>
            </mk-get-row>
            <mk-get-row>
                <el-form-item label="使用技术">
                    <el-input v-model="form.art" size="mini" class="input-one" clearable placeholder="请输入使用技术"></el-input>
                </el-form-item>
            </mk-get-row>
            <el-divider />
            <mk-get-button @save="save" @close="close(true)" />
        </el-form>
    </section>
</section>
</template>

<script>
import MkGetRow from "@/components/common/mk-get-row";
import MkGetButton from "@/components/common/mk-get-button";
import MkBackList from "@/components/common/mk-back-list";
import {
    projectCreate,
    projectUpdate
} from "@/api/modules/sys.personal.project.api";

export default {
    name: "get-project-info",
    components: {
        MkBackList,
        MkGetButton,
        MkGetRow
    },
    props: {
        updateData: {
            type: Object,
            default () {
                return {};
            }
        },
    },
    created() {

        if (this.updateData && this.updateData.id) {
            this.form = this.updateData
            this.isAdd = false
        }
    },
    data() {
        return {
            commonKey: 0,

            form: {
                show: 1
            },
            isAdd: true,
            rules: {
                name: [{
                    required: true,
                    message: '项目名称不能为空',
                    trigger: 'blur'
                }, ],
                startTime: [{
                    required: true,
                    message: '请选择开始时间',
                    trigger: 'blur'
                }, ],
                description: [{
                    required: true,
                    message: '请输入项目描述',
                    trigger: 'blur'
                }, ],
                duty: [{
                    required: true,
                    message: '请输入项目职责',
                    trigger: 'blur'
                }, ],

            }
        }
    },
    methods: {
        typeChange() {
            this.form.position = ""
        },
        save() {
            this.$refs['formAdd'].validate((valid) => {
                if (valid) {
                    let _FUC = ''
                    _FUC = this.isAdd ? projectCreate : projectUpdate
                    let msg = this.isAdd ? '添加成功！' : '修改成功！'
                    _FUC(this.form).then(res => {
                        this.$toast.success(msg)
                        this.$emit('close', true);
                    }).catch(err => {
                        console.log(err)
                    })
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        close(show) {
           
                this.$emit('close');
            
        }
    }
}
</script>

<style lang="scss" scoped>

</style>
